package com.testjpa.task;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;

/**
 * 作者: LCG
 * 日期: 2020/5/23 10:51
 * 描述:
 */

@Component
public class MyTask {

    @Autowired
    private RestTemplate restTemplate;

    @Value("${com.zbf.refreshpath}")
    private String refreshPath;


    /**
     * 刷新配置的任务方法
     */
    @Scheduled(cron = "0/1 * * * * ?")
    public void toRefreshConfig(){

        HashMap hashMap = new HashMap();
        restTemplate.postForObject(refreshPath,hashMap,String.class);
        System.out.println("=============执行任务=============");
    }

}
